_realname=slim-simulator
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.7
pkgrel=1
pkgdesc="SLiM forward simulation software package for population genetics (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://messerlab.org/slim/"
license=("GPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-cmake")
depends=("${MINGW_PACKAGE_PREFIX}-qt5-base")
source=("http://benhaller.com/slim/SLiM_pacman.tar.gz" )
sha256sums=("003f095120595b2a206fc2d7a451e2189a56639ae7b85a070b76c4ce13def391")

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
    ${MINGW_PREFIX}/bin/cmake.exe \
      -G"MSYS Makefiles" \
      -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
      -DBUILD_SLIMGUI=ON \
      ../SLiM_pacman

  ${MINGW_PREFIX}/bin/cmake.exe --build .
}

package() {
  cd "${srcdir}"/build-${MINGW_CHOST}

  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake.exe --install .

  install -Dm 644 "${srcdir}/SLiM_pacman/LICENSE" -t "${pkgdir}${MINGW_PREFIX}"/share/licenses/SLiM/
  install -Dm 644 "${srcdir}/SLiM_pacman/VERSIONS" "${srcdir}/SLiM_pacman"/README.md \
    -t "${pkgdir}${MINGW_PREFIX}"/share/doc/SLiM/
}